package com.tyk.bookstore.front.product.model.vo;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;

/**
 * @author tyk
 * @description 分类
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ClazzNestVo {

    @Schema(description = "ID")
    private Long id;

    @Schema(description = "名称")
    private String name;

    @Schema(description = "子项")
    private List<ClazzNestVo> children;

    /**
     * 添加子结点
     */
    public void addChild(ClazzNestVo vo) {
        if (this.children == null) this.children = new ArrayList<>();
        this.children.add(vo);
    }
}
